-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[nexus][saga] Fix saga node pagination, use Paginator API #5953
Conversation
@@ -103,54 +99,4 @@ impl DataStore { | |||
)), | |||
} | |||
} | |||
|
|||
pub async fn saga_list_unfinished_by_id( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that both these functions are only called once, and are already part of the db-queries
crate, I condensed them into saga_recovery.rs
.
This made it marginally easier to specify arguments, and means we can re-use the same pool connection for each batch we access.
This was mostly for a minor convenience, but I can keep the old structure if you had plans to actually call these functions from elsewhere.
ErrorHandler::NotFoundByLookup( | ||
ResourceType::SagaDbg, | ||
LookupType::ById(saga.id.0 .0), | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what the old code was doing but I don't think it's right? It may not matter. But if we get no rows here, that's not an error at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a test for this case, I think the "no node, no saga in db" case still returns a vec of length zero, so I'm pretty sure this is dead code. Updated to ErrorHandler::Server
to make this slightly more apparent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be super sure, I did a quick check and it looks to me like the ErrorHandler::NotFound*
variants only do anything special if the returned Diesel error variant is itself NotFound
, which only happens if we use first()
(first_async()
for us) or get_result()
(get_result_async()
for us). We're using load_async()
, and the NotFound
docs explicitly say load()
doesn't consider it an error to get 0 rows. So that explains why it didn't matter and yes I think the update you made makes sense. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Paginator
API for listing sagas and saga node events(node_id, event_type)
rather than bysaga_id
, which was previously incorrectBATCH_SIZE
boundary and check pagination order for both queriesFixes #5948